#ifndef TCPCLIENT_H
#define TCPCLIENT_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <arpa/inet.h>

#include <epicsThread.h>
#include <epicsEvent.h>
#include "epicsRingBytes.h"
#include "EventData.hpp"
#include "DataRingConsumeThread.hpp"



class TcpClient {
public:
	TcpSocketDataInfo *pTcpSocketDataInfo;
	int socket_id;
	bool do_recv;
    FILE *writeFD;
    TcpClient(TcpSocketDataInfo *);
    ~TcpClient();
    void createSocket();
	void start();
    void close();
    int receive(unsigned char *, int);
    void saveTofile(FILE *fd, unsigned char *buffer, int size);
    //void printErrorPackage(char *, int , int );
    //void printErrorPackage(char *, int , int );
private:
    
	struct addrinfo *pAddrinfo;
	epicsThread *pDataRingConsumeThread;
	

};

#endif